<#ftl output_format="HTML" auto_esc=true> 
<@h.commonHead title="后台管理系统" keywords="开源,永久免费" description="springrain开源系统管理后台"/>

<script src="${ctx}/js/validform/validform.min.js"></script>
<link rel="stylesheet" href="${ctx}/js/validform/validform.css" media="all">
<script>
	 var _active="${(returnDatas.data.active)!''}";
	 jQuery(function(){
		 jQuery("#active").val(_active);
		 /*
		 init_valid(_before,_after)
		 @_before:提交表单前，调用 的函数   可以为空，一般有validform处理不了，独自进行处理时使用
		 @_after:保存成功后，调用的函数  可以为空，一般为对应的列表页面
		 */
		 springrain.initValid(null,function(){window.location.href=springrain.appendToken("${ctx}/system/dicdata/${returnDatas.map.typekey}/list")});
	 });
	 function openLayer(){
		 layer.open({
			 type: 2,
			  title: '选择父级',
			  content: springrain.appendToken('${ctx}/system/dicdata/${returnDatas.map.typekey}/tree'),
			  area: ['500px', '600px'],
			  btn: ['确认', '取消'],
			  btn1:function(index, layero){
				  /*
				  var body = layer.getChildFrame('body', index);
				  console.log(body.html()) //得到iframe页的body内容
                  body.find("#dicDataTree");
				  */
                  var iframeWin = window[layero.find('iframe')[0]['name']]; //得到iframe页的窗口对象，执行iframe页的方法：iframeWin.method();
                  var _node=iframeWin.getSelect();
                  if(_node==null)return;
            
                  jQuery("#pname").val(_node[0].name);
          		  jQuery("#pid").val(_node[0].id);
          		layer.closeAll();
			  },
			  btn2: function(){
				    layer.closeAll();
			  }
			});     
			  
	 }
</script>
</head>
<body>
	<div class="layui-layout layui-layout-admin">
		<@h.naviHeader /> <@h.leftMenu />
		<!-- 主体内容开始 -->
			<div class="layui-tab layui-tab-brief">
				<ul class="layui-tab-title site-demo-title">
		             <li style="float:right;">
				        <button type="button" onclick="history.go(-1)" class="layui-btn layui-btn-small" style="margin-top:8px;"><i class="layui-icon layui-icon-specil">&#xe603;</i>返回</button>
		             </li>
	       		</ul>
	       		<div class="layui-body layui-tab-content site-demo-body">
					<div class="layui-tab-item layui-show">
							<div class="layui-main">
						          <div id="LAY_preview" class="layui-my-form">
				          				<header class="larry-personal-tit">
											<span>添加字典</span>
										</header>
										<!-- /header -->
										<div class="larry-personal-body clearfix changepwd">
											<form id="validForm" class="layui-form"  method="post" action="${ctx}/system/dicdata/${returnDatas.map.typekey}/update">
												<input type="hidden" name="id" value="${(returnDatas.data.id)!''}">
											 	<div class="layui-form-item col-lg-6">
													<label class="layui-form-label">名称*</label>
													<div class="layui-inline col-lg-5">  
													  	<input type="text" name="name" datatype="*" nullmsg="不能为空" errormsg="不能为空！" autocomplete="off" class="layui-input" value="${(returnDatas.data.name)!''}">
													</div>
													<div class="layui-inline valid-info"></div>
												</div>
												<div class="layui-form-item col-lg-6">
													<label class="layui-form-label">编码*</label>
													<div class="layui-inline">  
													  	<input type="text" name="code" datatype="*" nullmsg="不能为空" errormsg="不能为空！" autocomplete="off" class="layui-input"  value="${(returnDatas.data.code)!''}">
													</div>
													<div class="layui-inline valid-info"></div>
												</div>
												<div class="layui-form-item col-lg-6">
													<label class="layui-form-label">父级*</label>
													<div class="layui-inline">  
														<input id="pname" type="text" name="pname" datatype="*" nullmsg="不能为空" errormsg="不能为空！" readonly="readonly" autocomplete="off"  class="layui-input layui-disabled" value="">
													  	<input id="pid" type="hidden" name="pid" autocomplete="off"  class="layui-input"  value="${(returnDatas.data.name)!''}">
													</div>
													<div class="layui-inline">
														<button type="button" onclick="openLayer()" class="layui-btn layui-btn-normal"><i class="layui-icon">&#xe64c;</i>选择父级</button>
													</div>
													<div class="layui-inline valid-info"></div>
												</div>
												<div class="layui-form-item col-lg-6">
													<label class="layui-form-label">排序*</label>
													<div class="layui-inline">  
													  	<input type="text" name="sortno" datatype="*" nullmsg="不能为空" errormsg="不能为空！" autocomplete="off"  class="layui-input" value="${(returnDatas.data.sortno)!''}" >
													</div>
												</div>
												<div class="layui-form-item col-lg-6">
													<label class="layui-form-label">备注*</label>
													<div class="layui-inline  col-lg-6">  
													  	<textarea placeholder="请输入内容" datatype="*" nullmsg="不能为空" errormsg="不能为空！" name="remark" class="layui-textarea">${(returnDatas.data.remark)!''}</textarea>
													</div>
													<div class="layui-inline valid-info"></div>
												</div>
												<div class="layui-form-item col-lg-6">
													<label class="layui-form-label">是否可用</label>
													<div class="layui-inline">  
													  	<select name="active" id="active" class="form-control">
								                          <option value="">==请选择==</option>
														  <option value="1">是</option>
														  <option value="0">否</option>
														</select>   
													</div>
													<div class="layui-inline valid-info"></div>
												</div>
												<div class="layui-form-item change-submit  col-lg-6">
													<label class="layui-form-label"></label>
													<div class="layui-inline">
														<button type="button" class="layui-btn" id="smtbtn">保存</button>
														<button type="button" class="layui-btn layui-btn-primary" id="rstbtn">重置</button>
													</div>
												</div>
											</form>
										</div>
								  </div>
							</div>
					</div>
			</div>
		</div>
		<!-- 主体内容结束 -->
		<@h.footer />
	</div>
</body>
</html>

